package com.wjs.pool;

import java.util.concurrent.*;

public class ThreadDemo2 {
    public static void main(String[] args) {
        ExecutorService pool = new ThreadPoolExecutor(
                5,
                10,
                3,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(1),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
        );
        try {
            for (int i = 1; i <= 10; i++) {
                pool.execute(()->{
                    System.out.println(Thread.currentThread().getName()+"处理了业务");
                });
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            pool.shutdown();
        }
    }
}
